package cn.yunbamboos.mybatis.metadata;

import cn.yunbamboos.mybatis.Constants;
import cn.yunbamboos.mybatis.annotation.FieldStrategy;

import java.lang.reflect.Field;

/**
 * 基本信息
 * */
public class BaseInfo implements Comparable<BaseInfo>,Constants {

    // 属性
    protected final Field field;
    // 字段名
    protected final String column;
    // 属性名
    protected final String property;
    // 属性类型
    protected final Class<?> propertyType;
    protected final FieldStrategy fieldStrategy;
    // 排序
    protected final int sort;

    public BaseInfo(Field field, String column, String property, Class<?> propertyType,
                    FieldStrategy fieldStrategy, int sort) {
        this.field = field;
        this.column = column;
        this.property = property;
        this.propertyType = propertyType;
        this.fieldStrategy = fieldStrategy;
        this.sort = sort;
    }

    @Override
    public int compareTo(BaseInfo o) {
        return this.sort - o.sort;
    }

    public Field getField() {
        return field;
    }

    public String getColumn() {
        return column;
    }

    public String getProperty() {
        return property;
    }

    public FieldStrategy getFieldStrategy() {
        return fieldStrategy;
    }

    public Class<?> getPropertyType() {
        return propertyType;
    }

}
